package com.ivanjava.spbdemo1.service;

import com.ivanjava.spbdemo1.pojo.User;
import com.ivanjava.spbdemo1.pojo.dto.UserDTO;
import com.ivanjava.spbdemo1.repository.UserRepository;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService implements IUserService {

    @Autowired
    UserRepository userRepository;

    @Override
    public User add(UserDTO user) {
        //这里写业务
        User userPojo = new User();
        BeanUtils.copyProperties(user, userPojo);
        return userRepository.save(userPojo);
    }
}
